#include <stdio.h>
#include "textures.h"

texture_t wallTextures[9];

static const char *textureFileNames[9] =
    {
        "images/brick.png",
        "images/vent.png",
        "images/mossystone.png",
        "images/graystone.png",
        "images/colorstone.png",
        "images/bluestone.png",
        "images/wood.png",
        "images/poison.png",
        "images/mask.png"};

void loadWallTextures()
{
  int i = 0;
  upng_t *upng;

  for (i = 0; i < 9; i++)
  {
    upng = upng_new_from_file(textureFileNames[i]);
    if (!upng)
      continue;

    upng_decode(upng);
    if (upng_get_error(upng) != UPNG_EOK)
      continue;

    wallTextures[i].upngTexture = upng;
    wallTextures[i].width = upng_get_width(upng);
    wallTextures[i].height = upng_get_height(upng);
    wallTextures[i].texture_buffer = (colour_t *)upng_get_buffer(upng);
  }
}

void freeWallTextures()
{
  int i = 0;
  for (i = 0; i < 9; i++)
  {
    upng_free(wallTextures[i].upngTexture);
  }
}
